var global_fromid=0;
$(function(){
	log.debug('---index---');
	get_data();
	$(window).scroll(function(){
		log.debug($(document.body).height());
		log.debug($(window).height());
		log.debug($(document).scrollTop());
		var step_h = 100;
		var h = $(document).scrollTop();
		if(h>step_h && h<global_fromid * step_h){
			get_data(global_fromid);
		}
		
	})

	$('#obj').click(function(){
		$h.alert('我操');
	});
});
function get_data(id){
	id = id || 0;
	$h.load('/common/get_data', {limit:10, fromid:id}, function(data){
		log.debug(data);
		$.each(data, function(i){
			if(data[i].id>global_fromid){
				global_fromid = data[i].id;
			}
		});
		append_data(data);
		$('#content h1 img').remove();
	}, function(xht){
		$('#content h1').append('<img id="loading" src="/images/common_loading.gif" />');
	});
	
}
function append_data(d){
	for(var i=0; i<d.length; i++){
		$('article').append("<div>"+d[i].id+"--"+d[i].value+"</div>");
	}
}